<template>
  <el-input
    ref="input"
    v-bind="$attrs"
    v-on="$listeners"
  >
    <slot
      v-for="(slot, slotName) in $slots"
      :slot="slotName"
      :name="slotName"
    />
  </el-input>
</template>
<script>
import Vue from "vue";

Vue.directive('focus', function (el) {
  let input = el.querySelector('input');
  input.focus();
});
Vue.directive('textarea-focus', function (el) {
  let input = el.querySelector('textarea');
  input.focus();
});

/**
 * [输入框组件](https://element.eleme.cn/2.13/#/zh-CN/component/input)
 * @author maolin
 */
export default {
  name: 'EaInput',
  methods: {
    /**
     *  聚焦输入框
     * @public
     */
    focus () {
      this.$refs.input.focus();
    },
    /**
     * 取消聚焦输入框
     * @public
     */
    blur () {
      this.$refs.input.blur();
    },
    /**
     * 选择选项
     * @public
     */
    select () {
      this.$refs.input.select();
    }
  }
};
</script>
